<?php
/**
 * Template Name: Sidebar Template
 * Description: A Page Template that adds a sidebar to pages
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
global $current_single_idx;
get_header(); ?>

    	<div id="primary">
			<div id="content" role="main">
                <div id="slides">
                    <div class="slides_container">
                    <?php
                    // Cache the current post_id
                    
                    $current_post_id = $post->ID;
                    
                    $the_cats = get_the_category();
                    $curren_cat = $the_cats[0]->term_id;
					
					
                    query_posts( 'cat='.$curren_cat);

					/*
					
					$large_image_url = get_bloginfo('stylesheet_directory')."/images/home-default-image.png";
					if ( has_post_thumbnail()) {
						$large_image_urls = wp_get_attachment_image_src( get_post_thumbnail_id(), 'home-thumb');
						$large_image_url = $large_image_urls[0];
					}
					
					*/
					
					$post_array = null;
					
					
                    ?>
				    <?php while ( have_posts() ) : the_post(); ?>
                        <?php
							$post_array[$wp_query->current_post + 1] =  $post->ID;
						
                            if($post->ID == $current_post_id) {
                                $current_single_idx = $wp_query->current_post + 1;
                                // echo $current_single_idx;
                            }
							
                        ?>
					    <div id="post-<?php echo ($wp_query->current_post + 1) . '-' . $post->ID ; ?>">
                            <div class="col-1">
								<img src="<?php bloginfo('stylesheet_directory'); ?>/images/loading8.gif" alt=""/>
							</div>
							<div class="col-2">
								
							</div>
                        </div>
				    <?php endwhile; // end of the loop. ?>
					<?php
						js_localize('posts_index', array('default_img' => get_bloginfo('stylesheet_directory')."/images/home-default-image.png", 'data' => $post_array, 'current_idx' => $current_single_idx));
					?>
                    <?php wp_reset_query(); ?>
                     
                    </div>
                </div>
			</div><!-- #content -->
		</div><!-- #primary -->
        <script>
            jQuery(function($){
				
				
				jsonGetPostContent(posts_index.current_idx, $("#slides"));
				
            	jQuery('#slides').slides({
    				preload: true,
    				//generateNextPrev: true,
    				start: posts_index.current_idx,
					animationComplete: function(current){
						jsonGetPostContent(current, $("#slides"));
					}
    			});
    		});
        </script>
<?php get_sidebar('single'); ?>
<?php get_footer(); ?>